import request from '@/utils/request';

export interface Department {
  id: string;
  name: string;
  code: string;
  parentId?: string;
  companyId: string;
  status: 'active' | 'inactive';
  description?: string;
  createdAt: string;
  updatedAt: string;
}

export interface DepartmentListParams {
  page?: number;
  pageSize?: number;
  keyword?: string;
  companyId?: string;
  status?: string;
}

// 获取部门列表
export const getDepartments = (params?: DepartmentListParams) => {
  return request.get('/departments', { params });
};

// 获取单个部门
export const getDepartment = (id: string) => {
  return request.get(`/departments/${id}`);
};

// 创建部门
export const createDepartment = (data: Partial<Department>) => {
  return request.post('/departments', data);
};

// 更新部门
export const updateDepartment = (id: string, data: Partial<Department>) => {
  return request.put(`/departments/${id}`, data);
};

// 删除部门
export const deleteDepartment = (id: string) => {
  return request.delete(`/departments/${id}`);
};

